//封装获取频道列表的逻辑
import { useEffect,useState} from "react"
import { getChannelApi} from '@/apis/article'
function useChannel() {
  //1.获取频道列表所有的逻辑
  //获取频道列表
  const [channelList,setChannelList] =useState([])
  useEffect(() => {
    //1.封装函数 函数体内调用接口
    const getChannelList = async () =>{
      const res = await getChannelApi()
      setChannelList(res.data.channels)
    }
    //2.调用函数
    getChannelList()
  },[])
  //2.把组件中用到的数据return出去
  return {
    channelList
  }
}

export {
  useChannel
}